package myJs.myPkg.reactBootstrap

import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.{Children, JsComponent, JsFnComponent}
import japgolly.scalajs.react.facade.React
import japgolly.scalajs.react.vdom.VdomElement
import slinky.readwrite.ObjectOrWritten

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import scala.scalajs.js.|

object OverlayTrigger {

  case class Props(
      placement: js.UndefOr[String] = js.undefined,
      overlay: React.Element,
      trigger: js.UndefOr[String | js.Array[String]] = js.undefined
  )

  @js.native
  @JSImport("react-bootstrap", "OverlayTrigger")
  object RawComponent extends js.Object {}

  val Component = JsFnComponent[ObjectOrWritten[Props], Children.Varargs](RawComponent)

  def apply(
      placement: js.UndefOr[String] = js.undefined,
      overlay: React.Element,
      trigger: js.UndefOr[String | js.Array[String]] = js.undefined
  )(children: ChildArg*):VdomElement = Component(Props(placement, overlay, trigger))(children: _*)

}
